package com.study.shiro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.filter.DelegatingFilterProxy;

@SpringBootApplication
@ImportResource("classpath:/shiro-bean-config.xml")
public class ShiroSpringBootApplication {

    public static void main(String[] args) {
        SpringApplication.run(ShiroSpringBootApplication.class, args);
    }

    /**
     * 配置webFilter
     * @return
     */
    @Bean
    public FilterRegistrationBean<DelegatingFilterProxy> getShiroFilter() {
        FilterRegistrationBean<DelegatingFilterProxy> frb = new FilterRegistrationBean<>(new DelegatingFilterProxy("shiroFilter"));
        frb.addUrlPatterns("/*");
        frb.addInitParameter("targetFilterLiftCycle", "true");

        return frb;
    }

}
